<html  xmlns:th="http://www.thymeleaf.org" xmlns:v-on="http://www.w3.org/1999/xhtml"
       xmlns:v="http://www.w3.org/1999/xhtml" xmlns:v-bind="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
    <title>dati</title>

    <meta http-equiv="X-UA-Compatible" content="IE=Edge"/>
</head>
<body>
<style>

    .container{
        max-width: 1000px;
        min-height: 100%;
        background-color: transparent;
    }
</style>

<script src="/js/common.js"></script>
<div class="container" id="app" >

    <div class="post">

        <div class="form-group">
            <label>名称</label>
            <input type="text" class="form-control"  v-model="typeName">
        </div>
        <button  class="btn btn-primary  btn-block" v-on:click="addType()">新增</button>
    </div>

    <!--  </div>-->
</div>
<script th:inline="javascript">

    var app = new Vue({
        el: '#app',
        data: {
            typeName: '',
            items:[]
        },
        methods: {
            addType:function () {
                var params={
                    typeName:app.typeName,
                };
                $.ajax({
                    type : "post",
                    url : "/user/addType",
                    data : params,
                    success : function(data) {
                        if(data.code==200){
                            alert("新增成功");
                        }
                        else if(data.code==404){
                            alert("失败");
                        }
                        else {
                            alert("连接错误");
                        }
                        location.href="/toType";
                    }
                });
            }
        }
    });
</script>
</body>
</html>
